package newfangle.demos

import java.awt.{Color,BasicStroke,Stroke}
import java.awt.Color._
import java.awt.event.MouseEvent

import org.pwwong.fxscalautils.Predef._
import org.pwwong.fxscalautils.{FXScalaApp,DisplayMode}
import org.pwwong.fxscalautils.components.controls.{Button,Text,Rectangle,RoundRectangle}
import org.pwwong.fxscalautils.components.{Component, Draggable}
import org.pwwong.fxscalautils.components.layouthints._

import org.pwwong.scalautils.animation._
import org.pwwong.scalautils.animation.Predef._
import org.pwwong.scalautils.signals.Predef._

object BouncingBoxesDemo extends FXScalaApp(1024,768,DisplayMode.Windowed) {
  // Create a couple of Buttons
  val button1,button2,button3 = (new Button() text		   ( "Click Me!" )
                                              text('Hovered, "DO IT!")
                                              cornerRadius ( 50.0 )           // 50 pixel corner radius
                                              border	   ( 5 )              // 5 pixel border 
                                              anchor	   ( Center, Middle ) // Centered anchor point
                                              fillPaint('Hovered, orange )    // Filled orange when Hovered
                                              fillPaint('Pressed, red ) )     // Filled red when Pressed
  
  // Partially defined Animations
  val yAnimation    =  Bottom  -> Top     cycleInfinite
  val xAnimation    =  Right   -> Left    cycleInfinite 
  val sizeAnimation =  (10 %%) -> (30 %%) cycleInfinite
    
  // Layout
  contents(    
    button1 x		    ( xAnimation in(2 secs) )  y ( yAnimation in(5 secs) )  // Animate Position
            w           ( 30 %%                 )  h ( 30 %% )                  
            rotation    ( 0.0 -> 2.0*Math.Pi in(1 secs) repeatInfinite )        // Animate Rotation 
            fillPaint   ( magenta )
            borderPaint ( red ),
    
    button2 x		    ( xAnimation in(1 secs) )  y ( yAnimation in(10 secs) ) // Animate Position
            w           ( 20 %% )                  h ( 20 %% )	                
            cornerRadius( 0.0 -> 100.0 in(1 secs) cycleInfinite )               // Animate Corner Radius
            fillPaint	( cyan )
            border		( (new BasicStroke(0) -> new BasicStroke(25)) in(1 secs) cycleInfinite ) // Animate Border Size
            borderPaint	( blue ),
    
    button3 x		    ( Center )                 y ( Middle )                  // Animate Position   
            w		    (sizeAnimation in(1 secs)) h (sizeAnimation in(1 secs))  // Animate Size
            fillPaint	( green -> yellow in(1 secs) cycleInfinite )             // Animate Color
            fillPaint	( 'Hovered, blue -> red in(100 ms) cycleInfinite )       // Animate Color (Hover state)
            borderPaint	( green )
  )
  
}
